

#ENTER PARAMETERS HERE
DATAFOLDER=$WORK/NCDATA/july_cal_raw
CODEFOLDER=$WORK;
ROOTFOLDER=$WORK/NCDATA/root;
T2RFOLDER=trace2root

#-----------For comparison with old code------------#
#FILENAME=20110404_emptypercent_small_200mvdiv_0.83v #I overwrote this accidentally, no longer useful
#FILENAME=20110414_compatibility_check_200mvdiv_0.83v #Use 0.02v thresh, 62.6% empty, 9.12e8 maxcharge -1.22e9 mincharge
#---------------------------------------------------#

#-----------Data used to collect noise thresholds-----------#
#FILENAME=20110414_thresholds_200mvdiv_0.83v
#FILENAME=20110426_threshold_1vdiv_1v
#-----------------------------------------------------------#

#----------------------------Data---------------------------#
#FILENAME=20110420_seconddata_200mvdiv_0.83v
#FILENAME=20110420_firstdata_200mvdiv_0.83v
#FILENAME=20110427_data_1vdiv_1.2vgain
#-----------------------------------------------------------#

#FILENAME=20111007_AdaNano_Hot
#FILENAME=20111228_gaincal_good_1.00v
FILENAME=2013_07_21_A_cal95

#------------------------Thresholds-------------------------#
#VOLTAGETHRESHOLD=0.02;

#VOLTAGETHRESHOLD=0.04; #400pspt 200mvdiv 0.83vgain
#VARIANCETHRESHOLD=0.0067124; #400pspt 200mvdiv 0.83vgain

#VOLTAGETHRESHOLD=0.02; #400pspt 1vdiv 1vgain
VOLTAGETHRESHOLD=0.015; #400pspt 5mvdiv 0.87vbadgain
#VOLTAGETHRESHOLD=0.0075; #400pspt 10mvdiv 0.70vgain
#VOLTAGETHRESHOLD=0.02; #800pspt 50mvdiv 0.87vgain
#VOLTAGETHRESHOLD=0.030; #400pspt 100mvdiv 0.87vgain
#VOLTAGETHRESHOLD=0.075; #800pspt 200mvdiv 1vgain
#VOLTAGETHRESHOLD=0.150; #400pspt 500mvdiv 1.05vgain

VARIANCETHRESHOLD=0.036838; #400pspt 1vdiv 1vgain
#-----------------------------------------------------------#


NOISEHISTO=1; 
COUNTPEAKS=1;
CHARGEHISTO=1;
VARIANCEHISTO=0;
VARIANCECUT=0;
CUTZEROES=0;

DATANAME=_traces.bin;
HEADERNAME=_header.txt;
ROOTFILENAME=.root;
CHANNELS="ch=1";
ACHANNELS=1;
#NUMTRACES=200000;
#NUMTRACES=200000; #At 95% emptiness, this will give ~1e4 nonzero traces, which gives ~1% error (based on sqrt(n)/n)
#NUMTRACES=1000; # for testing thresholds
NUMTRACES=20000;

#FASTFRAME=10;
FASTFRAME=200;
MAXTIME=6000;

#RUN SCOPE PROGRAM
#echo ./teksoft $DATAFOLDER/$FILENAME $CHANNELS $NUMTRACES $FASTFRAME $MAXTIME;
#/home/wpauli/work/ttek/./teksoft $DATAFOLDER/$FILENAME $CHANNELS $NUMTRACES $FASTFRAME $MAXTIME;

#RUN ANALYSIS
echo;
echo RUNNING TraceToRoot;

#echo "r $DATAFOLDER/$FILENAME$DATANAME $DATAFOLDER/$FILENAME$HEADERNAME $ROOTFOLDER/$FILENAME$ROOTFILENAME $VOLTAGETHRESHOLD $NOISEHISTO $COUNTPEAKS $CHARGEHISTO $VARIANCEHISTO $VARIANCECUT $VARIANCETHRESHOLD $CUTZEROES" > args.dat
#
echo $CODEFOLDER/$T2RFOLDER/./TraceToRoot $DATAFOLDER/$FILENAME$DATANAME $DATAFOLDER/$FILENAME$HEADERNAME $ROOTFOLDER/$FILENAME$ROOTFILENAME $VOLTAGETHRESHOLD $NOISEHISTO $COUNTPEAKS $CHARGEHISTO $VARIANCEHISTO $VARIANCECUT $VARIANCETHRESHOLD $CUTZEROES $ACHANNELS;
$CODEFOLDER/$T2RFOLDER/./TraceToRoot $DATAFOLDER/$FILENAME$DATANAME $DATAFOLDER/$FILENAME$HEADERNAME $ROOTFOLDER/$FILENAME$ROOTFILENAME $VOLTAGETHRESHOLD $NOISEHISTO $COUNTPEAKS $CHARGEHISTO $VARIANCEHISTO $VARIANCECUT $VARIANCETHRESHOLD $CUTZEROES $ACHANNELS;
#gdb $CODEFOLDER/$T2RFOLDER/./TraceToRoot -command=args.dat

#VIEW HISTOGRAMS

#echo;
#echo VIEWING HISTOGRAMS;
#echo root -l $ROOTFOLDER/view_root_file.c;
#root -l $ROOTFOLDER/view_root_file.c;

#RUN ROOT
#ROOTCOMMAND="plot_gem.c(\""$DATAFOLDER/root/$FILENAME.root"\")"
#echo root -l $ROOTCOMMAND
#root -l $ROOTCOMMAND
#root -l $DATAFOLDER/root/$FILENAME.root 
